﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:SilverPop.UI.Controls">
	
	<Controls:Divide2Converter x:Key="Divide2Converter"/>

	<Style TargetType="Controls:DiagramCanvas">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="Controls:DiagramCanvas">
					<Border BorderBrush="#333333" BorderThickness="1" CornerRadius="10" Padding="{TemplateBinding Padding}">
						<Grid x:Name="DiagramContainerHost">
							<Canvas x:Name="PanContainer" Background="Transparent"/>
							<Canvas x:Name="ItemsContainer">
								<Canvas.RenderTransform>
									<TransformGroup>
										<TranslateTransform x:Name="ItemsContainerTranslateTransform"/>
										<ScaleTransform x:Name="ItemsContainerScaleTransform"
														ScaleX="{Binding ElementName=ZoomSlider, Path=Value, Mode=TwoWay}"
														ScaleY="{Binding ElementName=ZoomSlider, Path=Value, Mode=TwoWay}"/>
									</TransformGroup>
								</Canvas.RenderTransform>
							</Canvas>

							<Grid HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,100,100">
								<Border CornerRadius="8" Background="Silver" Opacity="0.75" Padding="5,5,5,5">
									<StackPanel Orientation="Vertical">
										<Slider x:Name="ZoomSlider" 
												Orientation="Vertical" 
												Minimum="0" Maximum="4" LargeChange="1" SmallChange="0.25" 
												Value="1.0" Width="50" Height="75"/>

										<Button x:Name="ButtonExtents" Height="25">
											Extents
										</Button>
									</StackPanel>
								</Border>
							</Grid>

						</Grid>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>

		<Setter Property="ItemTemplate">
			<Setter.Value>
				<DataTemplate>
					<Border 
						Width="{Binding W, Mode=TwoWay}" 
						Height="{Binding H, Mode=TwoWay}" 
						Canvas.Left="{Binding X, Mode=TwoWay}"
						Canvas.Top="{Binding Y, Mode=TwoWay}"
						Background="White" 
						BorderBrush="Black" 
						BorderThickness="1" 
						Padding="2,2,2,2">
						<Border.RenderTransform>
							<RotateTransform Angle="{Binding Angle, Mode=TwoWay}" 
											 CenterX="{Binding W, Converter={StaticResource Divide2Converter}}" 
											 CenterY="{Binding H, Converter={StaticResource Divide2Converter}}"/>
						</Border.RenderTransform>

						<TextBlock Text="{Binding Text}" TextAlignment="Center" TextWrapping="Wrap"/>
					</Border>				
				</DataTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="AdornerTemplate">
			<Setter.Value>
				<DataTemplate>
					<Grid
						Width="{Binding W, Mode=TwoWay}" 
						Height="{Binding H, Mode=TwoWay}" 
						Canvas.Left="{Binding X, Mode=TwoWay}"
						Canvas.Top="{Binding Y, Mode=TwoWay}">
						<Grid.RenderTransform>
							<RotateTransform Angle="{Binding Angle, Mode=TwoWay}" 
											 CenterX="{Binding W, Converter={StaticResource Divide2Converter}}" 
											 CenterY="{Binding H, Converter={StaticResource Divide2Converter}}"/>
						</Grid.RenderTransform>
						<Border
							Background="White" BorderBrush="Black" BorderThickness="1" 
							Padding="2,2,2,2">
							<TextBlock Text="{Binding Text, Mode=TwoWay}" TextAlignment="Center" TextWrapping="Wrap"/>
						</Border>

						<Rectangle Fill="Transparent"
									Stroke="Red"
									StrokeDashArray="2,1"
									StrokeThickness="2"
									Margin="-2,-2,-2,-2"/>

						<Line Stroke="Red" StrokeDashArray="2,1" StrokeThickness="2"
							HorizontalAlignment="Center" Y1="0" Y2="-50"/>

						<Thumb x:Name="ThumbTL" Margin="-10,-10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="10" Height="10" />
						<Thumb x:Name="ThumbBL" Margin="-10,0,0,-10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="10" Height="10" />
						<Thumb x:Name="ThumbTR" Margin="0,-10,-10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Width="10" Height="10"/>
						<Thumb x:Name="ThumbBR" Margin="0,0,-10,-10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="10" Height="10"/>
						<Thumb x:Name="ThumbROT" Margin="0,-50,0,0" HorizontalAlignment="Center" VerticalAlignment="Top" Width="10" Height="10"/>
						<Button x:Name="DeleteButton" HorizontalAlignment="Right" VerticalAlignment="Center" Content="X" Width="20" Margin="0,0,-20,0"/>

						<Canvas HorizontalAlignment="Center" VerticalAlignment="Bottom" 
								Margin="0,0,0,-70" Width="200" Height="60">
							<TextBox Text="{Binding Text, Mode=TwoWay}" Width="150" Height="50"/>
						</Canvas>

					</Grid>				
				</DataTemplate>
			</Setter.Value>
		</Setter>

	</Style>

</ResourceDictionary>
